package com.zsc.projectmanagementapi.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zsc.projectmanagementapi.dao.SearchMapper;
import com.zsc.projectmanagementapi.pojo.Do.Project;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Bernie_fang
 * @Description:
 * @create 2021/6/26 9:34
 **/
@Service
public class SearchServiceImpl {

    @Autowired
    private SearchMapper searchMapper;

    public List<String> findAllCategory() {
        return searchMapper.findAllCategory();
    }

    public List<Project> findProject(String name, String owner, String category) {
        if (!StringUtils.isEmpty(name)){
            name = "%" + name + "%";
        }
        if (!StringUtils.isEmpty(owner)){
            owner = "%" + owner + "%";
        }
        List<Project> projectList = searchMapper.findProject(name, owner, category);
        return projectList;
    }

}
